import VueRouter from 'vue-router'  // vue-router

import Login from '../pages/login.vue'
import Home from '../pages/home.vue'
import Echart from '../pages/HomeChilder/Echart.vue'
import WelCome from '../pages/HomeChilder/welcome.vue'
import Account from '../pages/HomeChilder/account.vue'
import SetEchart from '../pages/HomeChilder/SetEchart.vue'
import UserManage from '../pages/HomeChilder/UserManage.vue'


export default new VueRouter({
  routes:[
    {  // 路由重定向
      path:"/",
      redirect:"/login"
    },
    {
      path:"/login",
      component:Login,
      meta:{isLogin:true},
    },
    {
      path:"/home",
      component:Home,
      meta:{isLogin:true},
      children:[
        {
          path:"welcome",
          component:WelCome,
        },
        {
          path:"echart",
          component:Echart
        },
         {
          path:"dataAdmin",
          component:SetEchart
        },
         {
          path:"personnel",
          // component:Echart
        },
         {
          path:"user",
          component:UserManage
        },
         {
          path:"set",
          component:Account
        },
      ]
      // beforeEnter: (to, from, next) => {
      //   // console.log(localStorage.getItem("login_admin") === "true");
      //   if (to.meta.isLogin) {
      //     next()
      //   }else{
      //     console.log("我经过这个beforeEnter");
      //     next()
      //   }
        
      //   // ...
      // },
    }
  ]
})